package io.renren.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import io.renren.common.utils.CommonBusinessStatus;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.reflection.MetaObject;
import org.omg.CORBA.INTERNAL;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;
import java.util.Date;

@Slf4j
@Component
public class MyMetaObjectHandlerConfig implements MetaObjectHandler {
    @Override
    public void insertFill(MetaObject metaObject) {
        System.out.println("----- insert metaObject -----");

        //职位的状态管理
        this.strictInsertFill(metaObject,"jobApproveStatus",Integer.class, CommonBusinessStatus.POSITION_NOT_HAVE_APPROVE);
        //职位发布的状态管理
        this.strictInsertFill(metaObject,"jobIssueStatus",Integer.class,CommonBusinessStatus.POSITION_PUBLISH_NOT_HAVE);
        //职位招聘状态管理
        this.strictInsertFill(metaObject,"jobRecruitStatus", Integer.class,CommonBusinessStatus.POSITION_RECRUIT_ING);
        //职位是否通过审核
        this.strictInsertFill(metaObject,"jobIsPass",Integer.class,0);


        this.strictInsertFill(metaObject,"isDeleted",Integer.class,0);
        this.strictInsertFill(metaObject, "createTime", Date.class, new Date()); // 起始版本 3.3.0(推荐使用)
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); // 起始版本 3.3.0(推荐)
    }

    @Override
    public void updateFill(MetaObject metaObject) {
        System.out.println("----- update metaObject -----");
        this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date()); // 起始版本 3.3.0(推荐)
    }
}
